const http = require('http')

const tv = [
  { id: '001', type: 'textInput', model: 'name', width: '140', label: '会员姓名' },
  { id: '011', type: 'phoneCheck', model: 'phone', width: '140', label: '手机号码' },
  { id: '021', type: 'textInput', model: 'idcard', label: '身份证号', width: '70' },
  { id: '004', type: 'radio', model: 'gender', label: '性   别', width: '70' },
  { id: '023', type: 'textInput', model: 'height', label: '身高(CM)', width: '140' },
  { id: '024', type: 'textInput', model: 'weight', label: '体重(KG)', width: '140' },
  { id: '003', type: 'checkbox', model: 'like', label: '最擅长的泳姿', width: '200' },
]
const formid = '5846bcc7-63fd-49a6-a774-48728b349491'
const script = `update formlist set [tableView]='${JSON.stringify(tv)}' where id = '${formid}';`

const postData = JSON.stringify({ script })
const options = {
  hostname: 'www.ywjdzb.cn',
  port: 80,
  path: '/weixinNotify/AutoForm/AddItem',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json;charset=utf-8',
  },
}

const req = http.request(options, (res) => {
  console.log(`状态码: ${res.statusCode}`)
  res.on('data', (chunk) => {
    console.log(`响应主体: ${chunk}`)
  })
  res.on('end', () => {
    console.log('响应中已无数据')
  })
})

req.on('error', (error) => {
  console.error(`请求遇到问题: ${error.message}`)
})

req.write(postData)
req.end()
